package com.itita.ww2.data;

import com.smartfoxserver.v2.entities.data.ISFSObject;

public class MissionConfig {
	public static boolean isLoaded = false;
	// 
	private static ISFSObject missionList;
	private static ISFSObject config;
	private static ISFSObject task;
	//

	public static final void init(ISFSObject data) {
		config = data.getSFSObject("config");
		data.removeElement("config");
		// 
		task = data.getSFSObject("Task");
		data.removeElement("Task");
		// 
		missionList = data;
		MissionConfig.isLoaded = true;
	}

	/**
	 * 获取任务章节数据
	 */
	public static final ISFSObject getChapterData(String chapterId) {
		return missionList.getSFSObject(chapterId);
	}

	/**
	 * 获取关卡配置
	 */
	public static final ISFSObject getMissionConfig(String missionId) {
		return config.getSFSObject(missionId);
	}

	/**
	 * 获取某关卡需要花费的疲劳点
	 */
	public static final int getCostFatigue(String missionId) {
		return getMissionConfig(missionId).getInt("cost_common_fatigue");
	}

	/**
	 * 获取某关卡收获兵种经验
	 */
	public static final int getRewardArmyExp(String missionId) {
		return getMissionConfig(missionId).getSFSObject("reward").getInt("army_exp");
	}

	/**
	 * 获取某关卡收获将军经验
	 */
	public static final int getRewardGeneralExp(String missionId) {
		return getMissionConfig(missionId).getSFSObject("reward").getInt("general_exp");
	}

	/**
	 * 获取某关卡收获指挥官经验
	 */
	public static final int getRewardCommanderExp(String missionId) {
		return getMissionConfig(missionId).getSFSObject("reward").getInt("commander_exp");
	}

	/**
	 * 获取关卡扫荡奖励(额外)
	 */
	public static final ISFSObject getRewardRush(String missionId) {
		return getMissionConfig(missionId).getSFSObject("reward").getSFSObject("rush");
	}

	/**
	 * 获取关卡通关奖励(包含首次)
	 */
	public static final ISFSObject getRewardComplete(String missionId) {
		return getMissionConfig(missionId).getSFSObject("reward").getSFSObject("complete");
	}

	/**
	 * 获取关卡解锁数据
	 */
	public static final ISFSObject getUnlockData(String missionId) {
		return getMissionConfig(missionId).getSFSObject("unlock");
	}

	/**
	 * 关卡是否有兵种限制
	 */
	public static final boolean isArmyLimit(String missionId) {
		return getMissionConfig(missionId).getSFSObject("first_army_limit").size() > 0;
	}

	public static final ISFSObject getTask() {
		return task;
	}
}
